package com.fr.web.core.service;

import com.fr.base.FRContext;
import com.fr.base.core.html.Html;
import com.fr.base.core.html.Tag;
import com.fr.base.core.util.TemplateUtils;
import com.fr.report.FineBook;
import com.fr.report.ReportPage;
import com.fr.report.io.HTMLExportAttr;
import com.fr.report.io.ReportExportAttr;
import com.fr.web.Browser;
import com.fr.web.Repository;
import com.fr.web.core.HTMLConverter;
import com.fr.web.core.SessionIDInfor;
import com.fr.web.core.WebUtils;
import com.fr.web.core.chwriter.PageCellWriter;
import java.util.Map;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class JMeterService
{
  public static void dealWithJMeter(String paramString, HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
    throws Exception
  {
    FRContext.getLogger().info("Start convert reportpage to HTML tag for JMeter.....");
    long l1 = System.currentTimeMillis();
    int i = 1;
    String str = WebUtils.getHTTPRequestParameter(paramHttpServletRequest, "pn");
    if (str != null)
      i = Integer.parseInt(str);
    if (i <= 0)
      i = 1;
    SessionIDInfor localSessionIDInfor = SessionDealWith.getSessionIDInfor(paramString);
    if (localSessionIDInfor == null)
      return;
    ReportPage localReportPage = localSessionIDInfor.getReportPage(i);
    if (localReportPage == null)
      return;
    localSessionIDInfor.clearReportPageImages();
    Tag localTag = new Tag("div");
    Repository localRepository = new Repository(paramHttpServletRequest, localSessionIDInfor);
    PageCellWriter localPageCellWriter = new PageCellWriter(localRepository, 0, false);
    if (localRepository.getBrowser().shouldConsiderHeavyTD())
    {
      localObject = localSessionIDInfor.getContextBook().getReportExportAttr();
      if ((localObject != null) && (((ReportExportAttr)localObject).getHtmlExportAttr() != null))
      {
        HTMLExportAttr localHTMLExportAttr = ((ReportExportAttr)localObject).getHtmlExportAttr();
        if (localHTMLExportAttr.isTDHeavy())
          localPageCellWriter.setHeavy(true);
      }
    }
    new HTMLConverter(localReportPage, localPageCellWriter, null, localRepository, localTag, true).convert();
    if (localRepository.getBrowser().shouldWrapCenter())
    {
      localObject = localTag;
      localTag = new Tag("center").sub((Html)localObject);
    }
    Object localObject = WebUtils.context4PageTpl(paramHttpServletRequest, localSessionIDInfor);
    ((Map)localObject).put("body_content", localTag.toHtml());
    TemplateUtils.dealWithTemplate("/com/fr/web/core/page_debug.html", paramHttpServletResponse, (Map)localObject);
    long l2 = System.currentTimeMillis();
    FRContext.getLogger().info("Finish convert reportpage to HTML tag for JMeter. It takes " + (l2 - l1) + "ms");
  }
}